package com.woniu.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.woniu.entity.CarManager;
import com.woniu.entity.HouseManager;
import com.woniu.service.HouseManagerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;


@Api(value = "房屋信息模块", tags = {"抵质押物管理"})
@RestController
@RequestMapping("/houseProperty")
public class HouseManagerController extends BaseController {
    @Autowired
    HouseManagerService houseManagerService;

    @ApiOperation(value = "导出房屋信息列表", response= HouseManager.class,  httpMethod="GET", tags = {"抵质押物管理"})
    @ApiImplicitParam(name = "houseManager",value = "房屋信息实体",required = true)
    @PreAuthorize("@ss.hasPermi('test:export')")
    @Log(title = "贷款信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HouseManager houseManager) throws IOException {
        List<HouseManager> list=houseManagerService.exportmortList();
        ExcelUtil<HouseManager> util=new ExcelUtil<>(HouseManager.class);
        util.exportExcel(response,list,"房屋信息数据");
    }

    @ApiOperation(value = "查询所有房屋信息", response= HouseManager.class,  httpMethod="GET", tags = {"抵质押物管理"})
    @ApiImplicitParam(name = "houseManager",value = "房屋信息实体",required = true)
    @GetMapping("/findAll")
    public TableDataInfo findAll(HouseManager houseManager){
        startPage();
        List<HouseManager> list = houseManagerService.findAll(houseManager);
        return getDataTable(list);
    }

    @ApiOperation(value = "查询指定的房屋信息", response= HouseManager.class,  httpMethod="GET", tags = {"抵质押物管理"})
    @ApiImplicitParam(name = "houseManager",value = "房屋信息实体",required = true)
    @GetMapping("/{id}")
    public AjaxResult findOne(@PathVariable String id){
        return AjaxResult.success(houseManagerService.findOne(id));
    }

    @GetMapping("/exportList")
    public TableDataInfo exportmortList() {
        startPage();
        List<HouseManager> all = houseManagerService.exportmortList();
        return getDataTable(all);
    }
}
